#!/bin/sh
### BEGIN INIT INFO
# Provides:          james3
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:     $local_fs $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start Apache James 3
# Description:       Start the Apache James 3 mail server.
### END INIT INFO

. "/etc/environment"

# Workaround for the fact that the 32-bit wrapper executable is tried first
case "$(uname -s | tr '[:upper:]' '[:lower:]' | tr -d '[:blank:]')" in
	*linux*)
		case "$(uname -m | tr '[:upper:]' '[:lower:]' | tr -d '[:blank:]')" in
			amd64|x86_64)
				chmod -x "$DIRECT_HOME/apache-james-3.0-beta4/bin/wrapper-linux-x86-32"
				;;
			
			*)
				chmod +x "$DIRECT_HOME/apache-james-3.0-beta4/bin/wrapper-linux-x86-32"
				;;
		esac
		;;
esac

"$DIRECT_HOME/apache-james-3.0-beta4/bin/james" "$@"
